#!/bin/bash -f


#**************************************************************
#*                                                            *
#*      cleanup_files                                         *
#*                                                            *
#**************************************************************

function cleanup_files {
#
/bin/rm -f  exp1.db
/bin/rm -f  packets.tst
/bin/rm -f  ppr.db
/bin/rm -f  test_44_exp1_out
/bin/rm -f  test_44_exp1_out_restart
/bin/rm -f  test_44_ppr_out
/bin/rm -f  test_44_ppr_out_restart
/bin/rm -f  energy
#
}

#**************************************************************
#*                                                            *
#*      run_and_compare                                       *
#*                                                            *
#**************************************************************

function run_and_compare {
#
echo " "
echo "  ... running test_44 (ppr initial and restart job) ..."
"$warp3d_exe" $num_threads  < test_44_ppr > test_44_ppr_out
"$warp3d_exe" $num_threads  < test_44_ppr_restart > test_44_ppr_out_restart
echo "  ... WARP3D jobs completed for ppr model..."
perl check_44_ppr.perl

echo "  ... running test_44 (exponential initial and restart job) ..."
"$warp3d_exe" $num_threads  < test_44_exp1 > test_44_exp1_out
"$warp3d_exe" $num_threads  < test_44_exp1_restart > test_44_exp1_out_restart
perl check_44_exponential.perl
#
echo "  ... WARP3D jobs completed for exponential model..."
#
cleanup_files
#
}


#**************************************************************
#*                                                            *
#*      main programs                                         *
#*                                                            *
#**************************************************************
#
echo " "; echo " ";
#
machine=`uname`
echo ">> machine id: " $machine
num_threads=$NUM_THREADS
cleanup_files
#
if [ "$MACHINE_TYPE" = '0' ]; then
   echo -e "   OSX and Linux verification..."
   warp3d_exe="$WARP3D_EXE"
   run_and_compare
fi
if [ "$MACHINE_TYPE" = '1' ]; then
   echo -e "\n Windows 32-bit verification..."
   warp3d_exe="$WARP3D_EXE_32"
   run_and_compare
fi
if [ "$MACHINE_TYPE" = '2' ]; then
   echo -e "   Windows verification..."
   warp3d_exe="$WARP3D_EXE_64"
   run_and_compare
fi
#

#
echo -e "\n>>> All done with test_44 ...\n\n"
exit
